<?php

class Core_Action_Admin_System_Setting_Blacklist extends Action_Admin
{
	function execute($request, $initial = TRUE, $script = NULL)
	{
		if ($initial)
		{
			Agilet::setVar('breadcrum', array(
				array(
					'url' => 'admin/system',
					'label' => 'System'
				),
				array(
					'url' => 'admin/system/setting',
					'label' => 'setting'
				),
				array(
					'url' => 'admin/system/setting/blacklist',
					'label' => 'Blacklist'
				)
			));

		}

		$form = Form::factory('core/admin/setting/blacklist');

		$name = 'core/input';

		if ($request -> isGet())
		{
			$values = Config::instance() -> read($name);
			$form -> setData($values);
		}

		if ($request -> isPost() && $form -> isValid($_POST))
		{
			$value = $form -> getData();
			unset($value['buttons']);
			Config::instance() -> write($name, $value);
		}

		$request -> response = View::render('core/html/admin/edit', $data = array(
			'form' => $form,
			'title' => 'Black list'
		));
	}

}
